package controllers.sensors.implementation.tinkerforge;

import java.io.IOException;
import java.net.UnknownHostException;

import com.tinkerforge.AlreadyConnectedException;
import com.tinkerforge.BrickletAmbientLight;
import com.tinkerforge.BrickletTemperatureIR.AmbientTemperatureListener;
import com.tinkerforge.Device;
import com.tinkerforge.DeviceListener;
import com.tinkerforge.IPConnection;
import com.tinkerforge.NotConnectedException;

import controllers.sensors.implementation.AbstractSensor;

public class TFSensor extends AbstractSensor{
    
    private Device device;
    private IPConnection connection;
    private String host;
    private int port;
    
    public TFSensor(Device device, IPConnection connection, String host, int port) {
        this.device = device;
        this.connection = connection;
        this.host = host;
        this.port = port;
    }

    @Override
    public boolean connect() {
        try {
            connection.connect(host, port);
        } catch (UnknownHostException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (AlreadyConnectedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return true;
    }

    @Override
    public boolean disconnect() {
        try {
            connection.disconnect();
        } catch (NotConnectedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return true;
    }

}
